/*
*		Ö÷Òª½ÓÊÕ²Ù×÷£¬·â×°Ïß³Ì£¬¶Ë¿Ú£¬buffer
*/

#pragma once	

#include "CxTcpClient.h"
#include "CxType.h"
#include "CxThread.h"
#include "CxLinerBuffer.h"
#include "CxDataHandle.h"


BEGIN_NAMESPACE(DataRevPart)

class	CxRevThread		: public	CxThread
{
public:
    typedef		CxTcpClient::_ConnectFunc           _ConnectFunc;
    typedef     boost::signals2::signal<void()>     _BreakSignal;
public:
	CxRevThread(size_t number,const string & , UINT ,
		_ConnectFunc	_func=__EmptyFunc	/*Á¬½Ó»Øµ÷º¯Êý£¬¿ÉÓÃlambda±í´ïÊ½*/
		);

	CxRevThread(size_t number);

	~CxRevThread();

public:

	void		Start();
	void		Close();
	UINT		GetState()const{return m_state;}



	bool		OpenPort(const string &,UINT ,_ConnectFunc func=__EmptyFunc);


public:
	CxLinerBuffer &	GetBuffer(){return boost::ref(m_buffer);}

protected:
	void		RunFunc();

public:
    _BreakSignal    sig_break;
//²Ûº¯Êý
CX_SLOT:


	void		ConnectedFunc(bool	);
	void		BreakFunc();

private:
	
	bool			m_spin;
    bool            m_isconnect;
	size_t			m_number;
    size_t          m_portno;
	CxDataHandle	*m_phandle;
	CxTcpClient		*m_client;
    CxLinerBuffer	m_buffer;
    string          m_ipaddr;
};


END_NAMESPACE
